package com.ts.proj.task;

import com.ts.proj.ws.WebSocketServer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

@Slf4j
@Component
public class ScheduledService {

//    @Autowired
//    private WebSocketServer websocketService;

    private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");

    @Scheduled(cron = "0/5 * * * * *")
    public void scheduled(){
        //读数据
//        try {
//            websocketService.sendMessage("[" + Thread.currentThread().getName() + "]" + "现在时间：" + dateFormat.format(new Date()));
//        } catch (IOException e) {
//            e.printStackTrace();
//        }


        //置状态
    }
}
